
use std::fmt;

#[derive(Debug)]
struct AppErr;

impl fmt::Display for AppErr {
    // write macro will return a var with fmt::Result (Result<(), T>)
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "An error occurred, please try again!") // ; 
    }
}

fn process_error() -> Result<(), AppErr> {
    Err(AppErr)
}

fn main() {
    println!("Hello, world!");

    match process_error() {
        Err(msg) => eprintln!("{}", msg),
        _ => println!("No error"),
    }

    eprintln!("{:?}", process_error());
}


